package cn.shadow.game.chess.message;

import cn.shadow.moulde.Modules;
import cn.shadow.utils.BufferUtil;
import io.netty.buffer.ByteBuf;
import static cn.shadow.utils.BufferUtil.newDynamicMessage;
import static cn.shadow.utils.BufferUtil.onlySendHeaderMessage;
/**
* 两人对战棋类通用
* Created by CodeMaker
* Created time: 2020-08-19 12:15:30
*/
public class ChessModuleMessages {
    public static final int MODULE_ID = Modules.CHESS_MODULE_ID;


    /**
    *点击一个坐标
    */
    public static final int C2S_CHESS_CLICK=3001;

    /**
    *邀请玩家进行游戏
    */
    public static final int C2S_CHESS_INVITE_PLAYER=3003;

    /**
    *邀请玩家进行游戏
    */
    public static final int S2C_CHESS_INVITE_PLAYER=3004;
    public static ByteBuf InvitePlayerMsg(byte[] invitePlayer) {
        ByteBuf buffer = newDynamicMessage(MODULE_ID, S2C_CHESS_INVITE_PLAYER);

        BufferUtil.writeBytes(buffer,invitePlayer); //被邀请信息

        return buffer;
    }

    /**
    *接受邀请
    */
    public static final int C2S_CHESS_ACCEPT=3005;

    /**
    *邀请结果
    */
    public static final int S2C_CHESS_ACCEPT=3006;
    public static ByteBuf AcceptMsg(int chessType,String gameId,String inviteeName,boolean accept) {
        ByteBuf buffer = newDynamicMessage(MODULE_ID, S2C_CHESS_ACCEPT);

        BufferUtil.writeVarInt32(buffer,chessType); //游戏类型
        BufferUtil.writeUTF(buffer,gameId); //游戏id
        BufferUtil.writeUTF(buffer,inviteeName); //被邀请者
        BufferUtil.writeBoolean(buffer,accept); //接受或拒绝

        return buffer;
    }

    /**
    *发送开始开始对局请求
    */
    public static final int C2S_CHESS_START=3007;

    /**
    *开始对局响应,初始化棋盘
    */
    public static final int S2C_CHESS_START=3008;
    public static ByteBuf StartMsg(byte[] initBoard) {
        ByteBuf buffer = newDynamicMessage(MODULE_ID, S2C_CHESS_START);

        BufferUtil.writeBytes(buffer,initBoard); //初始化棋盘和玩家消息

        return buffer;
    }

}
